/*
 * @(#)DescriptionContent.java 0.0.1-SNAPSHOT
 *
 * Copyright Group B
 */

package grupb.upf.ms.impl;

import java.io.Serializable;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <p>This component implements a DescriptionContent Interface. In this case,
 * it cointains the properties of the content.</p>
 *
 *
 * @version    0.0.1-SNAPSHOT
 * @author     Group B
 */

public final class DescriptionContent
        implements grupb.upf.ms.DescriptionContent, Serializable {

    /**
     * The logger. A new logger <code>grupb.upf.ms.DescriptionContent</code>
     * is created to add the logs of this DescriptionContent.
     */
    private static final Log LOG = LogFactory.getLog(DescriptionContent.class);
    /**
     * The serialVersionUID is created to be able to serialize this class,
     * it's necessary because it will be sent.
     */
    private static final long serialVersionUID = 1L;
    /**
     * The properties of the object.
     */
    private Map < String, Object > property = null;

    /**
     * Constructor de la clase.
     */
    public DescriptionContent() {
     property = new Hashtable < String, Object > ();
    }
    /**
     * This method let us to add a property of the content.
     * @param prop is the name of the property
     * @param value is the value of this property
     */
    @Override
    public void addProperty(final String prop, final Object value) {
        this.property.put(prop, value);
    }

    /**
     * This method let us to get a property of the content.
     * @param prop is the name of the property
     * @return the value of this prop
     */
    @Override
    public Object getProperty(final String prop) {
        return this.property.get(prop);
    }

    /**
     * This method let us to recover an Array of all the names of the
     * properties which have been added.
     * @return an array of properties' names
     */
    @Override
    public String [] getPropertyNames() {
        String [] names = null;
        final Iterator it = this.property.entrySet().iterator();
        int i = 0;
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            names[i] = (String) e.getKey();
            i++;
        }
        return names;
    }
}
